package com.dominator.serviceImpl;

import com.dominFramework.core.typewrap.Dto;
import com.dominFramework.core.typewrap.Dtos;
import com.dominator.enums.ReqEnums;
import com.dominator.service.ApiGuaMachineService;
import com.dominator.utils.api.ApiMessage;
import com.dominator.utils.api.ApiMessageUtil;
import com.dominator.utils.api.ApiUtils;
import com.dominator.utils.exception.ApiException;
import com.dominator.utils.ocr.BaiduOcrUtils;
import com.dominator.utils.ocr.IntsigUtils;
import com.dominator.utils.qiniu.QiniuUploadFile;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

@Service
@Slf4j
public class ApiGuaMachineServiceImpl implements ApiGuaMachineService {



    @Override
    public ApiMessage sendTicketResult(Dto dto) throws ApiException {
        ApiUtils.checkParam(dto,"ticketNum,ticketRecoBase64,gamePriceId");
        //图片提交变成url
        String ocrRecoUrl ="";
        ocrRecoUrl=QiniuUploadFile.upload(dto.getString("ticketRecoBase64"),"jpg","ticketreco");
        String res= null;
        //res= IntsigUtils.ocrPictureByUrl(ocrRecoUrl);
        res= BaiduOcrUtils.getOcrResult(dto.getString("ticketRecoBase64"));

        Dto resDto= Dtos.newDto();
        resDto.put("res",res);

        //保存数据



        return ApiMessageUtil.success(resDto);
    }
}
